// component/company/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    data: {
      type: Array,
      value: []
    }
  },
  observers: {
    data(val) {
      if (val && val.length) {
        val.forEach(x => {
          let type = this.data.types.find(y => y.id == x.OperType)
          if (type) {
            x.OperTypeName = type.name
          }
          if (x.RelationList && x.RelationList.length) {
            let gd = x.RelationList.find(y => y.Type == '1')
            if (gd && gd.Value && gd.Value.indexOf('%') > -1) {
              x.CGBL = gd.Value
            }
            x.RelationList.forEach(y => {
              switch (y.Type) {
                case '3':
                  y.mode = 'danger'
                  break
                case '2':
                  y.mode = 'warning'
                  break
                case '1':
                  y.mode = 'success'
                  break
                default:
                  y.mode = 'primary'
                  break
              }
            })
          }
        })
      }

      this.setData({
        list: val
      })
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    list: [],
    types: [{
        id: '1',
        name: '法定代表人'
      },
      {
        id: '2',
        name: '执行事务合伙人'
      },
      {
        id: '3',
        name: '负责人'
      },
      {
        id: '4',
        name: '经营者'
      },
      {
        id: '5',
        name: '投资人'
      },
      {
        id: '6',
        name: '董事长'
      },
      {
        id: '7',
        name: '理事长'
      },
      {
        id: '8',
        name: '代表人'
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {}
})